using Slaks.Graphs.Algorithms.DistanceAlgorithm;
namespace Slaks.Graphs.Algorithms.ExperimentalDistances
{
	public class MCSseparate : GraphDistanceBase
	{
        public MCSseparate()
            : base()
        {
        }

        public MCSseparate(Graph one, Graph two) 
            : base ( one, two )
        {
        }		
		/// <summary>
		/// MCSseparate
		/// </summary>
		/// <param name="one"></param>
		/// <param name="two"></param>
		/// <returns></returns>
		public override double GetDistance()
		{
            double mcsRegular = new DistMCS4VertexEdgeCount(one, two).GetDistance();

			Graph maxCommonSubgraph = (one.GetMCS(two));
			double mcsVertexCount = maxCommonSubgraph.GetVertexCount();

			double graphSizeOneVertexCount = one.GetVertexCount();
			double graphSizeTwoVertexCount = two.GetVertexCount();

			double ratio;
			if (graphSizeOneVertexCount > graphSizeTwoVertexCount)
			{
				ratio = mcsVertexCount/graphSizeOneVertexCount;
				if (ratio >= 0.2) return 1 - ratio;
			}
			else
			{
				ratio = mcsVertexCount/graphSizeTwoVertexCount;
				if (ratio >= 0.2) return 1 - ratio;
			}

			return mcsRegular;
		}
	}
}